<?php

namespace App\Repository\Ai;

use App\Model\Ai\ChatModel;
use App\Model\Ai\ImageModel;
use App\Model\Ai\VideoModel;
use App\Repository\IRepository;
use Hyperf\Collection\Collection;
use Hyperf\Database\Model\Builder;

/**
 * 视频模型  Repository
 */
class
VideoModelRepository extends IRepository
{
    public function __construct(
        protected readonly VideoModel $model
    )
    {
    }

    public function handleSearch(Builder $query, array $params): Builder
    {

        $query->when(isset($params['name']) && $params['name'], function ($query) use ($params) {
            return $query->where('name', 'like', "%{$params['name']}%");
        });
        return $query;
    }




    public function handleOrderBy(Builder $query, $params): Builder
    {
        return $query->orderBy('sort', 'desc')
            ->orderBy('id', 'desc');
    }
}